﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;

namespace HY.Common
{
    public class ColorConvert : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values == null || values.Length < 2)
                return DependencyProperty.UnsetValue;
            double verValue = (double)values[0];
            double horValue = (double)values[1];
            if (verValue > horValue)
                return new SolidColorBrush(Colors.Green);
            else if (verValue < horValue)
                return new SolidColorBrush(Colors.Red);
            return new SolidColorBrush(Colors.Yellow);
        }
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            //返回空，标记不可双向转换
            return null;
        }
    }
}
